<?php

class Paginacao
{
	private $totalRegistrosPagina;
	public $totalRegistros;
	public $totalPaginas;
	public $total;
	public $pagina;
	public $limita;
	public $limitz;
	
	public function __construct($num)
	{
		$this->totalRegistros = $num;
	}
	
	public function setTotalRegistrosPagina($total)
	{
		$this->totalRegistrosPagina = $total;
		
		return $this;
	}
	
	public function setPaginaAtual($pagina)
	{
		$this->pagina = $pagina;
		
		return $this;
	}
	
	public function getTotalPaginas()
	{
		$tot = 4;
		$this->total = ceil($this->totalRegistros/$this->totalRegistrosPagina);
		$totalPaginas = $this->total;
		
		if($this->total > $tot)
		{
			$total = $this->pagina + $tot;
			
			if($total < $this->total)
			{
				$totalPaginas = $total;
			}
		}
		else
		{
			$i = 1;
		}
		
		while ($i <= $totalPaginas)
		{		
			$this->totalPaginas[] = $i;
			
			$i++;
		}
	}
	
	public function paginar()
	{
		$this->getTotalPaginas();
	}
}

?>
